# -*- coding: utf-8 -*-
# @Time    : 2023/6/3 19:49
# @Author  : 刘张宇
# @Email   : 2285524065@qq.com
# @File    : .py
# @Software: PyCharm

from appium.webdriver.common.mobileby import MobileBy as By
from pages.base_page import BasePage
from selenium.webdriver.support.select import Select

class Basket(BasePage):
    basket_locator = (By.XPATH, '//*[@text="菜篮子"]')#菜篮子
    add_ingredients_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/add"]"]')#点击食材用料
    ingredients_name_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/ingredientName"]')#添加食材名称
    ingredients_quantity_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/ingredientAmount"]')#添加数量
    finish_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/finishTv"]')#完成
    edit_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/more"]')#（清理）编辑
    delete_ingredients_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/deleteIngredientTv"]')#（清理）删除
    title_locator = (By.XPATH, '//*[@text="鸡肉"]')


    def menu_basket(self):
        self.find_element(self.basket_locator).click()#菜篮子

    def menu_add_ingredients(self):
        self.find_element(self.add_ingredients_locator).click()#点击食材用料

    def menu_ingredients_name(self,name):
        self.driver.find_element(*self.ingredients_name_locator).send_keys(name)#添加食材名称

    def menu_ingredients_quantity(self,ingredients):
        self.driver.find_element(*self.ingredients_quantity_locator).send_keys(ingredients)#添加数量

    def menu_finish(self):
        self.find_element(self.finish_locator).click()#完成

    def task_first(self):
        current_task = self.find_element(self.title_locator).text()#断言鸡肉
        return current_task

    def menu_ingredients_edit(self):
        self.find_element(self.edit_locator).click()#（清理）编辑

    def menu_ingredients_delete(self):
        self.find_element(self.delete_ingredients_locator).click()#（清理）删除
